<template>
	<web-view :src="url" ref="webview" @message="handleMessage"></web-view>
</template>

<script setup lang="ts">
	import { ref } from "vue";
	import { onLoad, onBackPress } from "@dcloudio/uni-app";
	const url = ref<string>("https://www.baidu.com?id=123");

   //webview跳h5 
	const handleMessage = () => {
		uni.$emit('webviewData', url.value)
		uni.reLaunch({
		  url: `/pages/index/index?data=${JSON.stringify(url.value)}`
		})
	}
	// 作为组件传参使用
	onLoad((options) => {
		console.log("web-view::", options);
		url.value = decodeURIComponent(options.url);
		if(url.value){
			handleMessage()
		}
	});
</script>